﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Text;

/// <summary>
/// Summary description for BKK
/// </summary>

namespace CE.Payment
{
    public class BKK
    {
        public BKK()
        {
            //
            // TODO: Add constructor logic here
            //
        }
        public void Payment(string amount, string orderRefno)
        {
            /*
            ***PRODUCTION URL***
            https://ipay.bangkokbank.com/b2c/eng/payment/payForm.jsp
            ********************************************************
    
            ***TESTING URL***
            https://psipay.bangkokbank.com/b2c/eng/payment/payForm.jsp
            */

            string Url = "https://ipay.bangkokbank.com/b2c/eng/payment/payForm.jsp";
            string formId = "myForm1";

            StringBuilder htmlForm = new StringBuilder();
            htmlForm.AppendLine("<html>");
            htmlForm.AppendLine(String.Format("<body onload='document.forms[\"{0}\"].submit()'>", formId));
            htmlForm.AppendLine(String.Format("<form id='{0}' method='POST' action='{1}'>", formId, Url));

            htmlForm.AppendLine("<input type='hidden' id='merchantId'  value='1757' />");
            //htmlForm.AppendLine("<input type='hidden' id='amount'  value='10.0' />");
            htmlForm.AppendLine("<input type='hidden' id='amount'  value=" + amount +"/>");
            //htmlForm.AppendLine("<input type='hidden' id='orderRef' value='20010207' />");
            htmlForm.AppendLine("<input type='hidden' id='orderRef' value=" + orderRefno+ "/>");
            htmlForm.AppendLine("<input type='hidden' id='currCode'  value='764' />");
            htmlForm.AppendLine("<input type='hidden' id='successUrl'  value='http://www.gluaygluay.com/Success.html' />");
            htmlForm.AppendLine("<input type='hidden' id='failUrl'  value='http://www.gluaygluay.com/Fail.html' />");
            htmlForm.AppendLine("<input type='hidden' id='cancelUrl'  value='http://www.gluaygluay.com/Cancel.html' />");
            htmlForm.AppendLine("<input type='hidden' id='payType'  value='N' />");
            htmlForm.AppendLine("<input type='hidden' id='lang'  value='E' />");
            htmlForm.AppendLine("<input type='hidden' id='remark' value='Testing - CompareXpress' />");
            
            //htmlForm.AppendLine("<input type='submit' id='btnSubmit' name='submit' />");

            htmlForm.AppendLine("</form>");
            htmlForm.AppendLine("</body>");
            htmlForm.AppendLine("</html>");

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(htmlForm.ToString());
            HttpContext.Current.Response.End();  
        }
    }

    
}
